package net.zjitc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.zjitc.entity.Jobhunting;
import net.zjitc.entity.VO.JobHuntingyonghuVo;
import net.zjitc.mapper.JobhuntingMapper;
import net.zjitc.service.IJobhuntingService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

/**
 * @auther 郭梦婷
 * @create 2022-05-10 14:22:24
 * @describe 服务实现类
 */
@Service
@Transactional
public class JobhuntingServiceImpl extends ServiceImpl<JobhuntingMapper, Jobhunting> implements IJobhuntingService {

    @Autowired
    private JobhuntingMapper jobhuntingMapper;

    @Override
    public Page<JobHuntingyonghuVo> getJobhuntings(String querystring, Integer pagenum, Integer pagesize) {
        Page<JobHuntingyonghuVo> page=new Page<>(pagenum,pagesize);
        if (querystring.length()==0){
            page = jobhuntingMapper.selectAlljobhunting(page);
        }else {
            QueryWrapper<JobHuntingyonghuVo> wrapper=new QueryWrapper<>();
            wrapper.like("username",querystring);
            page = jobhuntingMapper.selectjobhunting(page, wrapper);
        }

        return page;
    }

    @Override
    public JobHuntingyonghuVo selectById(Integer id) {
        JobHuntingyonghuVo jobHunting=jobhuntingMapper.getById(id);
        return jobHunting;
    }

    @Override
    public int deleteById(int id) {
        int i = deleteById(id);
        return i;
    }
}
